<%@page import="com.cn.bukeManage.utils.RSAUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.security.interfaces.*"%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}"
	scope="application" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>提现</title>
<link rel="stylesheet"
	href="${ctxPath}/static/js/data-tables/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css"
	href="${ctxPath}/static/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
<link href="${ctxPath}/static/css/style.css" rel="stylesheet">
<link href="${ctxPath}/static/css/style-responsive.css" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath }/static/images/lukebang320.ico" media="screen" />
<link rel="icon" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<style type="text/css">
.validateFontSize {
	font-size: 12px;
}
</style>
<%
	HashMap<String, Object> map = RSAUtils.getKeys();
	//生成公钥和私钥    
	RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
	RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
	session.setAttribute("privateKey", privateKey);//私钥保存在session中，用于解密  
	//公钥信息保存在页面，用于加密  
	String publicKeyExponent = publicKey.getPublicExponent().toString(16); //公钥指数   
	String publicKeyModulus = publicKey.getModulus().toString(16); //模    
	request.setAttribute("publicKeyExponent", publicKeyExponent);
	request.setAttribute("publicKeyModulus", publicKeyModulus);
%>
</head>
<body class="sticky-header">
	<%@ include file="../index/index.jsp"%>
	<section>
	<div class="main-content" style="overflow-y: auto">
		<!-- 地址栏-->
		<div class="page-heading">
			<h3>鹿客帮下单</h3>
			<ul class="breadcrumb">
				<li><a>任务管理</a></li>
				<li class="active">提现</li>
			</ul>
		</div>
		<!--这里是写一些内容的  -->
		<h3>&nbsp;&nbsp;&nbsp;提现：</h3>
		<form id="withDrawMoneyForm"
			class="form-horizontal left-align form-well">
			<div class="form-group">
				<label class="col-md-2 col-sm-2 control-label">账户名：</label>
				<div class="col-md-4">
					<input type="text" id="baoName" placeholder="支付宝姓名"
						class="form-control" name="baoName" style="width: 72%;">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 col-sm-2 control-label">支付宝账号：</label>
				<div class="col-md-4">
					<input type="text" id="zhifubaoAccount" placeholder="支付宝账号"
						class="form-control" maxlength="11" name="zhifubaoAccount" style="width: 72%;">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 col-sm-2 control-label">提现金额：</label>
				<div class="col-md-4">
					<input type="text" class="form-control" maxlength="11"
						name="withDrawMoney"
						style="width: 32%; display: inline-block; margin-right: 10px;"
						id="withDrawMoney">元
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 col-sm-2 control-label">输入密码：</label>
				<div class="col-md-4">
					<input type="password" placeholder="请输入登陆密码" class="form-control"
						maxlength="11" name="password" id="password" style="width: 72%;">
				</div>
			</div>
			<span class="btn btn-success"
			style="position: relative; float: right; margin-right: 72em; width: 90px"
			onclick="toWithDrawMoney()">提交</span>
		</form>
	</div>
	</section>

</body>
<script src="${ctxPath}/static/js/useful-toastr/toastr.min.js"></script>
<script src="${ctxPath}/static/js/useful-ewin/Ewin.js"></script>
<script src="${ctxPath}/static/js/security/security.js"></script>
<script type="text/javascript">
//////////////////////// START 提现啦啦啦啦//////////////////////////////////////////////
	function toWithDrawMoney() {
		var name=$('#baoName').val();
		var zhifubao= $('#zhifubaoAccount').val();//支付宝账号
		var restMoney = $('#restMoney').val();//当前余额
		var withDrawMoney = $('#withDrawMoney').val();//提现金额
		var password = $('#password').val();//密码
		password = password.split("").reverse().join("");
		RSAUtils.setMaxDigits(256);
		var key = new RSAUtils.getKeyPair("${publicKeyExponent}", "",
				"${publicKeyModulus}");//公钥
		var encrypedPwd = RSAUtils.encryptedString(key, password);
		//alert("name=" + name + ",zhifubao" + zhifubao+",restMoney" + restMoney+",withDrawMoney" + withDrawMoney+",password" + password);
		$.ajax({
			url : '${ctxPath }/merchant/alipyWithdrawal',
			type : 'post',
			dataType : 'JSON',
			data : {
				name : name,//姓名
				zhifubao : zhifubao,//支付宝账号
				restMoney : restMoney,//当前余额
				withdrawMoney : withDrawMoney,//提现金额
				password : encrypedPwd,
				status:1
			},
			success : function(data) {
				if(data.status==0){
					toastr.success("提现成功！");
					setTimeout(function(){
						window.location.reload(true);
					}, 10000);
				}else{
					toastr.error("提现失败！");
				}
			}
		});
	}

	//查询支付宝账号和支付宝姓名、账户当前余额
	$(document).ready(
			function() {
				toastr.options = {
					"closeButton" : false,
					"debug" : false,
					"positionClass" : "toast-top-center",
					"showDuration" : "300",
					"hideDuration" : "1000",
					"timeOut" : "5000",
					"extendedTimeOut" : "1000",
					"showEasing" : "swing",
					"hideEasing" : "linear",
					"showMethod" : "fadeIn",
					"hideMethod" : "fadeOut"
				};
				//alert("进来啦啦啦啦");
				$.post("${ctxPath }/merchant/getInitialInfomation", function(
						data) {
					//console.log(data);
					//console.log(data.zhifubao);
					//console.log(data.baoName);
					$("#withDrawMoneyForm input[name='wallet']").val(
							data.wallet.toFixed(2));
					$("#withDrawMoneyForm input[name='zhifubaoAccount']").val(
							data.zhifubao);
					$("#withDrawMoneyForm input[name='baoName']").val(
							data.baoName);
				})
			});
</script>
</html>
